      * cobc -x loggin.cbl
      *************************************************************************
       IDENTIFICATION DIVISION.
      *************************************************************************
       PROGRAM-ID. loggin.       
      *************************************************************************
       ENVIRONMENT DIVISION.
      *************************************************************************
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
       DECIMAL-POINT IS COMMA.	
      *************************************************************************
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT FileLog ASSIGN TO "prueba.log"       
       ORGANIZATION SEQUENTIAL
       ACCESS MODE SEQUENTIAL
       FILE STATUS IS FILE-STATUS-LOG.
      *************************************************************************
       DATA DIVISION.
      *************************************************************************
       FILE SECTION.
      *****************************************************
       FD FileLog.
       01 RegistroLog.
	  03 DATE-INI-LOG PIC X(1).
          03 DATE-LOG.
	           10  YEAR-LOG			PIC 9(04).
            	   10  FILLER1                  PIC X(1).
	           10  MONTH-LOG		PIC 9(02).
            	   10  FILLER2                  PIC X(1).
	           10  DAY-LOG			PIC 9(02).        
	  03 DATE-SPACE-LOG PIC X(1).
          03 TIME-LOG.
	       	   10  HOURS-LOG		PIC 9(02).
            	   10  FILLER3                  PIC X(1).
	       	   10  MINUTE-LOG		PIC 9(02).
            	   10  FILLER4                  PIC X(1).
	       	   10  SECOND-LOG		PIC 9(02).
            	   10  FILLER5                  PIC X(1).
	       	   10  MILLISECONDS-LOG  	PIC 9(02).
          03 DATE-END-LOG PIC X(1).
          03 MESSAGE-SPACE-LOG PIC X(1).
          03 MESSAGE-LOG PIC A(30).
      *****************************************************
       WORKING-STORAGE SECTION.
      *****************************************************	
       77 RES-EOF PIC XX VALUE  "NO".
          88 EOF            VALUE  "SI".
       77 FILE-STATUS-LOG PIC XX.
       01  CURRENT-DATE-DATA.
	       05  CURRENT-DATE.
	           10  CURRENT-YEAR			PIC 9(04).
	           10  CURRENT-MONTH			PIC 9(02).
	           10  CURRENT-DAY			PIC 9(02).
	       05  CURRENT-TIME.
	       	   10  CURRENT-HOURS		        PIC 9(02).
	       	   10  CURRENT-MINUTE		        PIC 9(02).
	       	   10  CURRENT-SECOND		        PIC 9(02).
	       	   10  CURRENT-MILLISECONDS	        PIC 9(02).
	       05  DIFF-FROM-GMT			PIC S9(04).	
      *************************************************************************
       PROCEDURE DIVISION.
      *************************************************************************
       Begin.
         PERFORM Inicio. 
	 PERFORM Fin.
         STOP RUN.         
      *********************************
	Inicio.
	PERFORM InicioLog.
      *********************************
	InicioLog.

	MOVE "[" TO DATE-INI-LOG.
      	MOVE "/" TO FILLER1.
      	MOVE "/" TO FILLER2.
	MOVE "" TO DAY-LOG.
      	MOVE ":" TO FILLER3.
      	MOVE ":" TO FILLER4.
      	MOVE ":" TO FILLER5.
	MOVE " " TO DATE-SPACE-LOG.
	MOVE "]" TO DATE-END-LOG.
	MOVE " " TO MESSAGE-SPACE-LOG.
	MOVE "" TO MESSAGE-LOG.

        OPEN OUTPUT FileLog.
      	IF FILE-STATUS-LOG NOT = ZERO
      		DISPLAY "ERROR  EN OPEN FS: " FILE-STATUS-LOG
      		STOP RUN.

      	MOVE "OPEN LOG OK" TO MESSAGE-LOG.
        PERFORM LOGGIN.
      *********************************
       LOGGIN.

       PERFORM LOGGIN-DATE.

       WRITE RegistroLog
       AFTER ADVANCING 1 LINES.
      *********************************
       LOGGIN-DATE.

       MOVE FUNCTION CURRENT-DATE TO CURRENT-DATE-DATA.

       MOVE CURRENT-YEAR TO YEAR-LOG.
       MOVE CURRENT-MONTH TO MONTH-LOG.
       MOVE CURRENT-DAY TO DAY-LOG.

       MOVE CURRENT-HOURS TO HOURS-LOG.
       MOVE CURRENT-MINUTE TO MINUTE-LOG.
       MOVE CURRENT-SECOND TO SECOND-LOG.
       MOVE CURRENT-MILLISECONDS TO MILLISECONDS-LOG.

       *********************************
	Fin.

      	MOVE "FIN PROGRAMA" TO MESSAGE-LOG.
        PERFORM LOGGIN.

        CLOSE FileLog.
      *********************************
       EXIT PROGRAM.

